<template>
    <div class="layout">
        <div class="box">
            <h1 class="login-title">xxx登录</h1>
            <Form ref="formCustom" :model="formCustom" :rules="ruleCustom" :label-width="0">
                <FormItem prop="username">
                    <Input type="text" v-model="formCustom.username" placeholder="用户名"></Input>
                </FormItem>
                <FormItem prop="passwd">
                    <Input type="password" v-model="formCustom.passwd" placeholder="密码"></Input>
                </FormItem>
                <FormItem>
                    <Button type="primary" @click="handleSubmit('formCustom')" to="/layout" long>登录</Button>
                </FormItem>
            </Form>
        </div>
    </div>
</template>
<script type="text/ecmascript-6">
    export default {
        data () {
            const validateUsername = (rule, value, callback)=>{

            };
            const validatePass = (rule, value, callback) => {

            };
            return {
                formCustom: {
                    username: '',
                    passwd: ''
                },
                ruleCustom: {
                    username: [
                        {validator: validateUsername, trigger: 'blur'}
                    ],
                    passwd: [
                        {validator: validatePass, trigger: 'blur'}
                    ]
                }
            }
        },
        methods: {
            handleSubmit (name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.$Message.success('Success!');
                    } else {
                        this.$Message.error('Fail!');
                    }
                })
            }
        }
    }
</script>
<style scoped>
    .layout {
        width: 100%;
        height: 100%;
        background-color: #2a7aec;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .box {
        width: 320px;
        height: 306px;
    }

    h1 {
        text-align: center;
        margin-bottom: 30px;
        color: #fff;
    }
</style>
